package com.ymatou.iapi.productmanager.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;

public class ActivityProductStartSaleCall extends YmatouAutoTestCall{
	private static String opurl ="/api/Product/ActivityProductStartSale";
	
	public ActivityProductStartSaleCall() {
		super(EnvSetup.getSystemUrl("productmanager"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	public JSONObject call(int userId, int liveId,List<String> productIdList){
		Map<String, Object> updateMap = new HashMap<String, Object>();
		updateMap.put("UserId", userId);
		updateMap.put("ActivityId", liveId);
		updateMap.put("ProductIds", new JSONArray(productIdList));

		return callAndGetReturnData(updateMap);
	}
	
	
	
	public static void main(String[] args) {
		List<Integer> numList = Arrays.asList(123,32454,34543,5464,67856,78768,768768,78,32423,453);
		List<Integer> Max2Num = new ArrayList<>();
		
		for(int i=0;i<numList.size();i++){
			if (Max2Num.size()<2){
				Max2Num.add(numList.get(i));
			}else{
				if (Max2Num.get(0)>Max2Num.get(1)){
					int MaxNum = Max2Num.get(0);
					int MinNum = Max2Num.get(1);
					Max2Num.clear();
					Max2Num.add(MinNum);
					Max2Num.add(MaxNum);
				}
				
				if (Max2Num.get(0)<numList.get(i)){
					Max2Num.remove(0);
					Max2Num.add(numList.get(i));
				}
			}
		}
		
		
		
		
		
		System.out.println(Max2Num);
	}
}
